Changeset 772 for GPL/trunk/lib32


Ignore:
Timestamp:
Apr 19, 2025, 8:08:37 PM (7 months ago)
Author:
David Azarewicz
Message:

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

Location:
GPL/trunk
Files:
1 deleted
17 edited
1 copied

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/lib32/Makefile

    r679 r772  
    3030  strncmp.obj timer.obj kobject.obj driver.obj drivers_base.obj &
    3131  instropl2.obj instropl3.obj vsprintf.obj bitmap.obj find_next_bit.obj &
    32   regmap.obj regcache.obj regcache-flat.obj regcache-rbtree.obj
     32  regmap.obj regcache.obj regcache-flat.obj regcache-rbtree.obj &
     33  component.obj
    3334
    3435TARGET = linuxlib
  • GPL/trunk/lib32/bitmap.c

    r679 r772  
    512512                        int nmaskbits)
    513513{
    514         if (!access_ok(VERIFY_READ, ubuf, ulen))
     514        if (!access_ok(ubuf, ulen))
    515515                return -EFAULT;
    516516        return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits);
     
    704704                        int nmaskbits)
    705705{
    706         if (!access_ok(VERIFY_READ, ubuf, ulen))
     706        if (!access_ok(ubuf, ulen))
    707707                return -EFAULT;
    708708        return __bitmap_parselist((const char *)ubuf,
  • GPL/trunk/lib32/devres.c

    r717 r772  
    99
    1010#include <linux/device.h>
     11#include <linux/pci.h>
    1112#include <linux/module.h>
    1213#include <linux/slab.h>
    1314#include <linux/gfp.h>
    1415#include <linux/errno.h>
     16#include <asm/io.h>
    1517
    1618struct devres_node {
    1719        struct list_head                entry;
    1820        dr_release_t                    release;
    19 #ifdef CONFIG_DEBUG_DEVRES
    2021        const char                      *name;
    2122        size_t                          size;
    22 #endif
    2323};
    2424
     
    2626        struct devres_node              node;
    2727        /* -- 3 pointers */
    28         unsigned long long              data[]; /* guarantee ull alignment */
     28        u8              data[]; /* guarantee ull alignment */
    2929};
    3030
     
    3636};
    3737
     38static void set_node_dbginfo(struct devres_node *node, const char *name,
     39                             size_t size)
     40{
     41        node->name = name;
     42        node->size = size;
     43}
     44
    3845#define devres_log(dev, node, op)       do {} while (0)
    3946
     
    7683}
    7784
    78 #define devres_log(dev, node, op)       do {} while (0)
    79 
    8085static void add_dr(struct device *dev, struct devres_node *node)
    8186{
    8287        devres_log(dev, node, "ADD");
    8388        BUG_ON(!list_empty(&node->entry));
    84 //#ifndef TARGET_OS2
    85         /* Traps here on OS/2 */
    8689        list_add_tail(&node->entry, &dev->devres_head);
    87 //#endif
    8890}
    8991
     
    99101void devres_add(struct device *dev, void *res)
    100102{
    101         /* Traps here on OS/2 */
    102103        struct devres *dr = container_of(res, struct devres, data);
    103104        unsigned long flags;
     105
    104106        spin_lock_irqsave(&dev->devres_lock, flags);
    105107        add_dr(dev, &dr->node);
     
    108110
    109111/**
    110  * devres_alloc - Allocate device resource data
     112 * __devres_alloc_node - Allocate device resource data
    111113 * @release: Release function devres will be associated with
    112114 * @size: Allocation size
    113115 * @gfp: Allocation flags
    114116 * @nid: NUMA node
     117 * @name: Name of the resource
    115118 *
    116119 * Allocate devres of @size bytes.  The allocated area is zeroed, then
     
    121124 * Pointer to allocated devres on success, NULL on failure.
    122125 */
    123 void * devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid)
     126void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid,
     127                          const char *name)
    124128{
    125129        struct devres *dr;
    126130
    127131        dr = alloc_dr(release, size, gfp | __GFP_ZERO, nid);
     132        if (unlikely(!dr))
     133                return NULL;
     134        set_node_dbginfo(&dr->node, name, size);
    128135        return dr->data;
    129136}
     
    214221}
    215222
    216 static int release_nodes(struct device *dev, struct list_head *first,
    217                          struct list_head *end, unsigned long flags)
    218 {
    219 //      LIST_HEAD(todo);
    220         struct list_head todo;
    221 
    222         int cnt;
     223static void release_nodes(struct device *dev, struct list_head *todo)
     224{
    223225        struct devres *dr, *tmp;
    224 
    225         cnt = remove_nodes(dev, first, end, &todo);
    226 
    227         spin_unlock_irqrestore(&dev->devres_lock, flags);
    228226
    229227        /* Release.  Note that both devres and devres_group are
    230228         * handled as devres in the following loop.  This is safe.
    231229         */
    232         list_for_each_entry_safe_reverse(dr, tmp, &todo, node.entry, struct devres) {
     230        list_for_each_entry_safe_reverse(dr, tmp, todo, node.entry, struct devres) {
    233231                devres_log(dev, &dr->node, "REL");
    234232                dr->node.release(dev, dr->data);
    235233                kfree(dr);
    236234        }
    237 
    238         return cnt;
    239235}
    240236
     
    249245{
    250246        unsigned long flags;
     247        struct list_head todo;
     248        int cnt;
    251249
    252250        /* Looks like an uninitialized device structure */
    253251        if (WARN_ON(dev->devres_head.next == NULL))
    254252                return -ENODEV;
     253
     254        /* Nothing to release if list is empty */
     255        if (list_empty(&dev->devres_head))
     256                return 0;
     257
    255258        spin_lock_irqsave(&dev->devres_lock, flags);
    256         return release_nodes(dev, dev->devres_head.next, &dev->devres_head,
    257                              flags);
    258 }
     259        cnt = remove_nodes(dev, dev->devres_head.next, &dev->devres_head, &todo);
     260        spin_unlock_irqrestore(&dev->devres_lock, flags);
     261
     262        release_nodes(dev, &todo);
     263        return cnt;
     264}
     265
     266/**
     267 * devres_open_group - Open a new devres group
     268 * @dev: Device to open devres group for
     269 * @id: Separator ID
     270 * @gfp: Allocation flags
     271 *
     272 * Open a new devres group for @dev with @id.  For @id, using a
     273 * pointer to an object which won't be used for another group is
     274 * recommended.  If @id is NULL, address-wise unique ID is created.
     275 *
     276 * RETURNS:
     277 * ID of the new group, NULL on failure.
     278 */
     279void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
     280{
     281        struct devres_group *grp;
     282        unsigned long flags;
     283
     284        grp = kmalloc(sizeof(*grp), gfp);
     285        if (unlikely(!grp))
     286                return NULL;
     287
     288        grp->node[0].release = &group_open_release;
     289        grp->node[1].release = &group_close_release;
     290        INIT_LIST_HEAD(&grp->node[0].entry);
     291        INIT_LIST_HEAD(&grp->node[1].entry);
     292        set_node_dbginfo(&grp->node[0], "grp<", 0);
     293        set_node_dbginfo(&grp->node[1], "grp>", 0);
     294        grp->id = grp;
     295        if (id)
     296                grp->id = id;
     297
     298        spin_lock_irqsave(&dev->devres_lock, flags);
     299        add_dr(dev, &grp->node[0]);
     300        spin_unlock_irqrestore(&dev->devres_lock, flags);
     301        return grp->id;
     302}
     303EXPORT_SYMBOL_GPL(devres_open_group);
     304
     305/* Find devres group with ID @id.  If @id is NULL, look for the latest. */
     306static struct devres_group * find_group(struct device *dev, void *id)
     307{
     308        struct devres_node *node;
     309
     310        list_for_each_entry_reverse(node, &dev->devres_head, entry, struct devres_node) {
     311                struct devres_group *grp;
     312
     313                if (node->release != &group_open_release)
     314                        continue;
     315
     316                grp = container_of(node, struct devres_group, node[0]);
     317
     318                if (id) {
     319                        if (grp->id == id)
     320                                return grp;
     321                } else if (list_empty(&grp->node[1].entry))
     322                        return grp;
     323        }
     324
     325        return NULL;
     326}
     327
     328/**
     329 * devres_release_group - Release resources in a devres group
     330 * @dev: Device to release group for
     331 * @id: ID of target group, can be NULL
     332 *
     333 * Release all resources in the group identified by @id.  If @id is
     334 * NULL, the latest open group is selected.  The selected group and
     335 * groups properly nested inside the selected group are removed.
     336 *
     337 * RETURNS:
     338 * The number of released non-group resources.
     339 */
     340int devres_release_group(struct device *dev, void *id)
     341{
     342        struct devres_group *grp;
     343        unsigned long flags;
     344        struct list_head todo;
     345        int cnt = 0;
     346
     347        spin_lock_irqsave(&dev->devres_lock, flags);
     348
     349        grp = find_group(dev, id);
     350        if (grp) {
     351                struct list_head *first = &grp->node[0].entry;
     352                struct list_head *end = &dev->devres_head;
     353
     354                if (!list_empty(&grp->node[1].entry))
     355                        end = grp->node[1].entry.next;
     356
     357                cnt = remove_nodes(dev, first, end, &todo);
     358                spin_unlock_irqrestore(&dev->devres_lock, flags);
     359
     360                release_nodes(dev, &todo);
     361        } else {
     362                WARN_ON(1);
     363                spin_unlock_irqrestore(&dev->devres_lock, flags);
     364        }
     365
     366        return cnt;
     367}
     368EXPORT_SYMBOL_GPL(devres_release_group);
    259369
    260370static struct devres *find_dr(struct device *dev, dr_release_t release,
     
    306416
    307417/**
     418 * devres_get - Find devres, if non-existent, add one atomically
     419 * @dev: Device to lookup or add devres for
     420 * @new_res: Pointer to new initialized devres to add if not found
     421 * @match: Match function (optional)
     422 * @match_data: Data for the match function
     423 *
     424 * Find the latest devres of @dev which has the same release function
     425 * as @new_res and for which @match return 1.  If found, @new_res is
     426 * freed; otherwise, @new_res is added atomically.
     427 *
     428 * RETURNS:
     429 * Pointer to found or added devres.
     430 */
     431void * devres_get(struct device *dev, void *new_res,
     432                  dr_match_t match, void *match_data)
     433{
     434        struct devres *new_dr = container_of(new_res, struct devres, data);
     435        struct devres *dr;
     436        unsigned long flags;
     437
     438        spin_lock_irqsave(&dev->devres_lock, flags);
     439        dr = find_dr(dev, new_dr->node.release, match, match_data);
     440        if (!dr) {
     441                add_dr(dev, &new_dr->node);
     442                dr = new_dr;
     443                new_res = NULL;
     444        }
     445        spin_unlock_irqrestore(&dev->devres_lock, flags);
     446        devres_free(new_res);
     447
     448        return dr->data;
     449}
     450EXPORT_SYMBOL_GPL(devres_get);
     451
     452/*
     453 * Custom devres actions allow inserting a simple function call
     454 * into the teadown sequence.
     455 */
     456
     457struct action_devres {
     458        void *data;
     459        void (*action)(void *);
     460};
     461
     462static void devm_action_release(struct device *dev, void *res)
     463{
     464        struct action_devres *devres = res;
     465
     466        devres->action(devres->data);
     467}
     468
     469/**
    308470 * devm_add_action() - add a custom action to list of managed resources
    309471 * @dev: Device that owns the action
     
    316478int devm_add_action(struct device *dev, void (*action)(void *), void *data)
    317479{
     480        struct action_devres *devres;
     481
     482        devres = devres_alloc(devm_action_release,
     483                              sizeof(struct action_devres), GFP_KERNEL);
     484        if (!devres)
     485                return -ENOMEM;
     486
     487        devres->data = data;
     488        devres->action = action;
     489
     490        devres_add(dev, devres);
     491
    318492        return 0;
    319493}
     
    331505{
    332506}
     507
     508/*
     509 * Managed kmalloc/kfree
     510 */
     511static void devm_kmalloc_release(struct device *dev, void *res)
     512{
     513        /* noop */
     514}
     515
     516/**
     517 * devm_kmalloc - Resource-managed kmalloc
     518 * @dev: Device to allocate memory for
     519 * @size: Allocation size
     520 * @gfp: Allocation gfp flags
     521 *
     522 * Managed kmalloc.  Memory allocated with this function is
     523 * automatically freed on driver detach.  Like all other devres
     524 * resources, guaranteed alignment is unsigned long long.
     525 *
     526 * RETURNS:
     527 * Pointer to allocated memory on success, NULL on failure.
     528 */
     529void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
     530{
     531        struct devres *dr;
     532
     533        if (unlikely(!size))
     534                return ZERO_SIZE_PTR;
     535
     536        /* use raw alloc_dr for kmalloc caller tracing */
     537        dr = alloc_dr(devm_kmalloc_release, size, gfp, dev_to_node(dev));
     538        if (unlikely(!dr))
     539                return NULL;
     540
     541        /*
     542         * This is named devm_kzalloc_release for historical reasons
     543         * The initial implementation did not support kmalloc, only kzalloc
     544         */
     545        set_node_dbginfo(&dr->node, "devm_kzalloc_release", size);
     546        devres_add(dev, dr->data);
     547        return dr->data;
     548}
     549EXPORT_SYMBOL_GPL(devm_kmalloc);
     550
     551enum devm_ioremap_type {
     552        DEVM_IOREMAP = 0,
     553        DEVM_IOREMAP_UC,
     554        DEVM_IOREMAP_WC,
     555        DEVM_IOREMAP_NP,
     556};
     557
     558void devm_ioremap_release(struct device *dev, void *res)
     559{
     560        iounmap(*(void __iomem **)res);
     561}
     562
     563static void *__devm_ioremap(struct device *dev, resource_size_t offset,
     564                                    resource_size_t size,
     565                                    enum devm_ioremap_type type)
     566{
     567        void __iomem **ptr, *addr = NULL;
     568
     569        ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
     570        if (!ptr)
     571                return NULL;
     572
     573        switch (type) {
     574        case DEVM_IOREMAP:
     575                addr = ioremap(offset, size);
     576                break;
     577#if 0
     578        case DEVM_IOREMAP_UC:
     579                addr = ioremap_uc(offset, size);
     580                break;
     581        case DEVM_IOREMAP_WC:
     582                addr = ioremap_wc(offset, size);
     583                break;
     584        case DEVM_IOREMAP_NP:
     585                addr = ioremap_np(offset, size);
     586                break;
     587#endif
     588        }
     589
     590        if (addr) {
     591                *ptr = addr;
     592                devres_add(dev, ptr);
     593        } else
     594                devres_free(ptr);
     595
     596        return addr;
     597}
     598
     599/**
     600 * devm_ioremap - Managed ioremap()
     601 * @dev: Generic device to remap IO address for
     602 * @offset: Resource address to map
     603 * @size: Size of map
     604 *
     605 * Managed ioremap().  Map is automatically unmapped on driver detach.
     606 */
     607void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
     608                           resource_size_t size)
     609{
     610        return __devm_ioremap(dev, offset, size, DEVM_IOREMAP);
     611}
     612EXPORT_SYMBOL(devm_ioremap);
     613
     614/**
     615 * devm_kvasprintf - Allocate resource managed space and format a string
     616 *                   into that.
     617 * @dev: Device to allocate memory for
     618 * @gfp: the GFP mask used in the devm_kmalloc() call when
     619 *       allocating memory
     620 * @fmt: The printf()-style format string
     621 * @ap: Arguments for the format string
     622 * RETURNS:
     623 * Pointer to allocated string on success, NULL on failure.
     624 */
     625char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
     626                      va_list ap)
     627{
     628        unsigned int len;
     629        char *p;
     630        va_list aq;
     631
     632        va_copy(aq, ap);
     633        len = vsnprintf(NULL, 0, fmt, aq);
     634        va_end(aq);
     635
     636        p = devm_kmalloc(dev, len+1, gfp);
     637        if (!p)
     638                return NULL;
     639
     640        vsnprintf(p, len+1, fmt, ap);
     641
     642        return p;
     643}
     644EXPORT_SYMBOL(devm_kvasprintf);
     645/**
     646 * devm_kasprintf - Allocate resource managed space and format a string
     647 *                  into that.
     648 * @dev: Device to allocate memory for
     649 * @gfp: the GFP mask used in the devm_kmalloc() call when
     650 *       allocating memory
     651 * @fmt: The printf()-style format string
     652 * @...: Arguments for the format string
     653 * RETURNS:
     654 * Pointer to allocated string on success, NULL on failure.
     655 */
     656char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
     657{
     658        va_list ap;
     659        char *p;
     660
     661        va_start(ap, fmt);
     662        p = devm_kvasprintf(dev, gfp, fmt, ap);
     663        va_end(ap);
     664
     665        return p;
     666}
     667EXPORT_SYMBOL_GPL(devm_kasprintf);
     668
     669/*
     670 * PCI iomap devres
     671 */
     672#define PCIM_IOMAP_MAX  PCI_STD_NUM_BARS
     673
     674struct pcim_iomap_devres {
     675        void __iomem *table[PCIM_IOMAP_MAX];
     676};
     677
     678static void pcim_iomap_release(struct device *gendev, void *res)
     679{
     680        struct pci_dev *dev = to_pci_dev(gendev);
     681        struct pcim_iomap_devres *this = res;
     682        int i;
     683
     684        for (i = 0; i < PCIM_IOMAP_MAX; i++)
     685                if (this->table[i])
     686                        pci_iounmap(dev, this->table[i]);
     687}
     688
     689/**
     690 * pcim_iomap_table - access iomap allocation table
     691 * @pdev: PCI device to access iomap table for
     692 *
     693 * Access iomap allocation table for @dev.  If iomap table doesn't
     694 * exist and @pdev is managed, it will be allocated.  All iomaps
     695 * recorded in the iomap table are automatically unmapped on driver
     696 * detach.
     697 *
     698 * This function might sleep when the table is first allocated but can
     699 * be safely called without context and guaranteed to succeed once
     700 * allocated.
     701 */
     702void __iomem * const *pcim_iomap_table(struct pci_dev *pdev)
     703{
     704        struct pcim_iomap_devres *dr, *new_dr;
     705
     706        dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL);
     707        if (dr)
     708                return dr->table;
     709
     710        new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL);
     711        if (!new_dr)
     712                return NULL;
     713        dr = devres_get(&pdev->dev, new_dr, NULL, NULL);
     714        return dr->table;
     715}
     716EXPORT_SYMBOL(pcim_iomap_table);
     717
     718/**
     719 * pcim_iomap - Managed pcim_iomap()
     720 * @pdev: PCI device to iomap for
     721 * @bar: BAR to iomap
     722 * @maxlen: Maximum length of iomap
     723 *
     724 * Managed pci_iomap().  Map is automatically unmapped on driver
     725 * detach.
     726 */
     727void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)
     728{
     729        void __iomem **tbl;
     730
     731        BUG_ON(bar >= PCIM_IOMAP_MAX);
     732
     733        tbl = (void __iomem **)pcim_iomap_table(pdev);
     734        if (!tbl || tbl[bar])   /* duplicate mappings not allowed */
     735                return NULL;
     736
     737        tbl[bar] = pci_iomap(pdev, bar, maxlen);
     738        return tbl[bar];
     739}
     740EXPORT_SYMBOL(pcim_iomap);
     741
     742/**
     743 * pcim_iounmap - Managed pci_iounmap()
     744 * @pdev: PCI device to iounmap for
     745 * @addr: Address to unmap
     746 *
     747 * Managed pci_iounmap().  @addr must have been mapped using pcim_iomap().
     748 */
     749void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr)
     750{
     751        void __iomem **tbl;
     752        int i;
     753
     754        pci_iounmap(pdev, addr);
     755
     756        tbl = (void __iomem **)pcim_iomap_table(pdev);
     757        BUG_ON(!tbl);
     758
     759        for (i = 0; i < PCIM_IOMAP_MAX; i++)
     760                if (tbl[i] == addr) {
     761                        tbl[i] = NULL;
     762                        return;
     763                }
     764        WARN_ON(1);
     765}
     766EXPORT_SYMBOL(pcim_iounmap);
     767
     768/**
     769 * pcim_iomap_regions - Request and iomap PCI BARs
     770 * @pdev: PCI device to map IO resources for
     771 * @mask: Mask of BARs to request and iomap
     772 * @name: Name used when requesting regions
     773 *
     774 * Request and iomap regions specified by @mask.
     775 */
     776int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name)
     777{
     778        void __iomem * const *iomap;
     779        int i, rc;
     780
     781        iomap = pcim_iomap_table(pdev);
     782        if (!iomap)
     783                return -ENOMEM;
     784
     785        for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
     786                unsigned long len;
     787
     788                if (!(mask & (1 << i)))
     789                        continue;
     790
     791                rc = -EINVAL;
     792                len = pci_resource_len(pdev, i);
     793                if (!len)
     794                        goto err_inval;
     795
     796                rc = pci_request_region(pdev, i, (char*)name);
     797                if (rc)
     798                        goto err_inval;
     799
     800                rc = -ENOMEM;
     801                if (!pcim_iomap(pdev, i, 0))
     802                        goto err_region;
     803        }
     804
     805        return 0;
     806
     807 err_region:
     808        pci_release_region(pdev, i);
     809 err_inval:
     810        while (--i >= 0) {
     811                if (!(mask & (1 << i)))
     812                        continue;
     813                pcim_iounmap(pdev, iomap[i]);
     814                pci_release_region(pdev, i);
     815        }
     816
     817        return rc;
     818}
     819EXPORT_SYMBOL(pcim_iomap_regions);
  • GPL/trunk/lib32/driver.c

    r717 r772  
    557557//                      goto probe_failed;
    558558        }
    559 #ifdef TARGET_OS2xxx
     559#ifdef NOT_USED
    560560        driver_bound(dev);
    561561        ret = 1;
     
    613613                else if (drv->remove)
    614614                        drv->remove(dev);
    615                 devres_release_all(dev);
     615//              devres_release_all(dev);
    616616                dev->driver = NULL;
    617617                klist_remove(&dev->p->knode_driver);
  • GPL/trunk/lib32/drivers_base.c

    r679 r772  
    173173         */
    174174        drv = dev->driver;
     175#if 0
    175176        return drv ? drv->name :
    176177                        (dev->bus ? dev->bus->name :
    177178                        (dev->class ? dev->class->name : ""));
     179#else
     180        return "uniaud32";
     181#endif
    178182}
     183
     184int device_match_name(struct device *dev, const void *name)
     185{
     186        return sysfs_streq(dev_name(dev), name);
     187}
     188EXPORT_SYMBOL_GPL(device_match_name);
     189
     190int device_match_of_node(struct device *dev, const void *np)
     191{
     192        return dev->of_node == np;
     193}
     194EXPORT_SYMBOL_GPL(device_match_of_node);
  • GPL/trunk/lib32/internal.h

    r679 r772  
    274274
    275275extern struct regcache_ops regcache_rbtree_ops;
    276 extern struct regcache_ops regcache_lzo_ops;
     276extern struct regcache_ops regcache_maple_ops;
    277277extern struct regcache_ops regcache_flat_ops;
    278278
  • GPL/trunk/lib32/irq.c

    r604 r772  
    249249//******************************************************************************
    250250
     251/*
     252 * Device resource management aware IRQ request/free implementation.
     253 */
     254struct irq_devres {
     255        unsigned int irq;
     256        void *dev_id;
     257};
     258
     259static void devm_irq_release(struct device *dev, void *res)
     260{
     261        struct irq_devres *this = res;
     262
     263        free_irq(this->irq, this->dev_id);
     264}
     265
     266/**
     267 *      devm_request_threaded_irq - allocate an interrupt line for a managed device
     268 *      @dev: device to request interrupt for
     269 *      @irq: Interrupt line to allocate
     270 *      @handler: Function to be called when the IRQ occurs
     271 *      @thread_fn: function to be called in a threaded interrupt context. NULL
     272 *                  for devices which handle everything in @handler
     273 *      @irqflags: Interrupt type flags
     274 *      @devname: An ascii name for the claiming device, dev_name(dev) if NULL
     275 *      @dev_id: A cookie passed back to the handler function
     276 *
     277 *      Except for the extra @dev argument, this function takes the
     278 *      same arguments and performs the same function as
     279 *      request_threaded_irq().  IRQs requested with this function will be
     280 *      automatically freed on driver detach.
     281 *
     282 *      If an IRQ allocated with this function needs to be freed
     283 *      separately, devm_free_irq() must be used.
     284 */
     285int devm_request_threaded_irq(struct device *dev, unsigned int irq,
     286                              irq_handler_t handler, irq_handler_t thread_fn,
     287                              unsigned long irqflags, const char *devname,
     288                              void *dev_id)
     289{
     290        struct irq_devres *dr;
     291        int rc;
     292
     293        dr = devres_alloc(devm_irq_release, sizeof(struct irq_devres),
     294                          GFP_KERNEL);
     295        if (!dr)
     296                return -ENOMEM;
     297
     298        if (!devname)
     299                devname = dev_name(dev);
     300
     301        rc = request_irq(irq, handler, irqflags, devname,
     302                                  dev_id);
     303        if (rc) {
     304                devres_free(dr);
     305                return rc;
     306        }
     307
     308        dr->irq = irq;
     309        dr->dev_id = dev_id;
     310        devres_add(dev, dr);
     311
     312        return 0;
     313}
  • GPL/trunk/lib32/memory.c

    r679 r772  
    424424void *__vmalloc(unsigned long size, gfp_t gfp_mask)
    425425{
    426         return vmalloc(size);
     426    LINEAR addr;
     427    addr = (LINEAR) vmalloc(size);
     428
     429    if (gfp_mask & __GFP_ZERO)
     430        memset((LINEAR)addr, 0, size);
     431
     432    return addr;
    427433}
    428434//******************************************************************************
     
    610616
    611617//******************************************************************************
     618//******************************************************************************
    612619#ifdef DEBUGHEAP
    613620void *__kmalloc(int size, int flags, const char *filename, int lineno)
     
    626633    }
    627634    if(size >= 4096) {
    628         return vmalloc(size);
    629     }
     635        addr = (LINEAR)vmalloc(size);
     636    } else {
    630637#ifdef DEBUGHEAP
    631     addr = (LINEAR)malloc(size, filename, lineno);
     638        addr = (LINEAR)malloc(size, filename, lineno);
    632639#else
    633     addr = (LINEAR)malloc(size);
     640        addr = (LINEAR)malloc(size);
    634641#endif
     642    }
    635643    if(addr == NULL) {
    636644        DebugInt3();
    637645        return 0;
    638646    }
     647    if (flags & __GFP_ZERO)
     648        memset((LINEAR)addr, 0, size);
    639649        //dprintf(("kmalloc %d returned %x", size, addr));
    640650    return addr;
    641651}
    642652
     653//******************************************************************************
    643654//******************************************************************************
    644655#ifdef DEBUGHEAP
     
    668679
    669680//******************************************************************************
    670 void *kzalloc(size_t size, unsigned int flags)
    671 {
    672         void *ret;
    673         ret = _kmalloc(size, flags);
    674         if (ret)
    675                 memset(ret, 0, size);
    676         return ret;
    677 }
    678 //******************************************************************************
    679681//******************************************************************************
    680682void *kcalloc(size_t n, size_t size, unsigned int flags)
     
    773775        return buf;
    774776}
     777
    775778//******************************************************************************
    776779//******************************************************************************
  • GPL/trunk/lib32/misc.c

    r679 r772  
    2828#include <linux/init.h>
    2929#include <linux/fs.h>
     30#include <linux/of.h>
    3031#include <linux/poll.h>
    3132#define CONFIG_PROC_FS 1
     
    3940#include <linux/firmware.h>
    4041#include <linux/ctype.h>
     42#include <linux/math64.h>
    4143#include <dbgos2.h>
    4244
    4345void StringOut(char *DbgStr);
     46extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
    4447
    4548struct new_utsname system_utsname = {0};
     
    784787        free_pages((unsigned long) ptr, pg);
    785788}
     789
     790/**
     791 * of_node_put() - Decrement refcount of a node
     792 * @node:       Node to dec refcount, NULL is supported to simplify writing of
     793 *              callers
     794 */
     795void of_node_put(struct device_node *node)
     796{
     797        if (node)
     798                kobject_put(&node->kobj);
     799}
     800
     801/**
     802 * sysfs_streq - return true if strings are equal, modulo trailing newline
     803 * @s1: one string
     804 * @s2: another string
     805 *
     806 * This routine returns true iff two strings are equal, treating both
     807 * NUL and newline-then-NUL as equivalent string terminations.  It's
     808 * geared for use with sysfs input strings, which generally terminate
     809 * with newlines but are compared against values without newlines.
     810 */
     811bool sysfs_streq(const char *s1, const char *s2)
     812{
     813        while (*s1 && *s1 == *s2) {
     814                s1++;
     815                s2++;
     816        }
     817
     818        if (*s1 == *s2)
     819                return true;
     820        if (!*s1 && *s2 == '\n' && !s2[1])
     821                return true;
     822        if (*s1 == '\n' && !s1[1] && !*s2)
     823                return true;
     824        return false;
     825}
     826EXPORT_SYMBOL(sysfs_streq);
     827
     828u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
     829{
     830        u32 high = divisor >> 32;
     831        u64 quot;
     832
     833        if (high == 0) {
     834                u32 rem32;
     835                quot = div_u64_rem(dividend, divisor, &rem32);
     836                *remainder = rem32;
     837        } else {
     838                int n = fls(high);
     839                quot = div_u64(dividend >> n, divisor >> n);
     840
     841                if (quot != 0)
     842                        quot--;
     843
     844                *remainder = dividend - quot * divisor;
     845                if (*remainder >= divisor) {
     846                        quot++;
     847                        *remainder -= divisor;
     848                }
     849        }
     850
     851        return quot;
     852}
     853
     854/**
     855 * memset32() - Fill a memory area with a uint32_t
     856 * @s: Pointer to the start of the area.
     857 * @v: The value to fill the area with
     858 * @count: The number of values to store
     859 *
     860 * Differs from memset() in that it fills with a uint32_t instead
     861 * of a byte.  Remember that @count is the number of uint32_ts to
     862 * store, not the number of bytes.
     863 */
     864void *memset32(uint32_t *s, uint32_t v, size_t count)
     865{
     866        uint32_t *xs = s;
     867
     868        while (count--)
     869                *xs++ = v;
     870        return s;
     871}
     872EXPORT_SYMBOL(memset32);
     873
     874/**
     875 *      sysfs_emit - scnprintf equivalent, aware of PAGE_SIZE buffer.
     876 *      @buf:   start of PAGE_SIZE buffer.
     877 *      @fmt:   format
     878 *      @...:   optional arguments to @format
     879 *
     880 *
     881 * Returns number of characters written to @buf.
     882 */
     883int sysfs_emit(char *buf, const char *fmt, ...)
     884{
     885        va_list args;
     886        int len;
     887
     888#ifdef NOT_USED
     889        if (WARN(!buf || offset_in_page(buf),
     890                 "invalid sysfs_emit: buf:%p\n", buf))
     891                return 0;
     892#endif
     893
     894        va_start(args, fmt);
     895        len = vscnprintf(buf, PAGE_SIZE, fmt, args);
     896        va_end(args);
     897
     898        return len;
     899}
     900EXPORT_SYMBOL_GPL(sysfs_emit);
     901
     902/**
     903 *      sysfs_emit_at - scnprintf equivalent, aware of PAGE_SIZE buffer.
     904 *      @buf:   start of PAGE_SIZE buffer.
     905 *      @at:    offset in @buf to start write in bytes
     906 *              @at must be >= 0 && < PAGE_SIZE
     907 *      @fmt:   format
     908 *      @...:   optional arguments to @fmt
     909 *
     910 *
     911 * Returns number of characters written starting at &@buf[@at].
     912 */
     913int sysfs_emit_at(char *buf, int at, const char *fmt, ...)
     914{
     915        va_list args;
     916        int len;
     917
     918#ifdef NOT_USED
     919        if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE,
     920                 "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at))
     921                return 0;
     922#endif
     923
     924        va_start(args, fmt);
     925        len = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args);
     926        va_end(args);
     927
     928        return len;
     929}
     930EXPORT_SYMBOL_GPL(sysfs_emit_at);
  • GPL/trunk/lib32/ossidc.c

    r709 r772  
    6464
    6565cardcalls_t cardcalls[CARDS_NUM] = {
     66        { CARD_AZX,      &name_module_init(azx_driver_init),            &name_module_exit(azx_driver_exit)        },
    6667        { CARD_ICH,      &name_module_init(intel8x0_driver_init),       &name_module_exit(intel8x0_driver_exit)   },
    6768        { CARD_VIA82XX,  &name_module_init(via82xx_driver_init),        &name_module_exit(via82xx_driver_exit)    },
     
    8990        { CARD_ATIIXP,   &name_module_init(atiixp_driver_init),         &name_module_exit(atiixp_driver_exit)     },
    9091        { CARD_AUDIGYLS, &name_module_init(ca0106_driver_init),         &name_module_exit(ca0106_driver_exit)     },
    91         { CARD_AZX,      &name_module_init(azx_driver_init),            &name_module_exit(azx_driver_exit)        },
    9292        { CARD_BT87X,    &name_module_init(alsa_card_bt87x_init),       &name_module_exit(alsa_card_bt87x_exit)   },
    9393};
  • GPL/trunk/lib32/pci.c

    r717 r772  
    3030#include <linux/poll.h>
    3131#include <linux/dma-mapping.h>
     32#include <linux/gfp.h>
    3233#include <asm/uaccess.h>
    3334#include <asm/hardirq.h>
     
    205206        pcidev->dev.dma_mask = &pcidev->dma_mask;
    206207        pcidev->dev.coherent_dma_mask = 0xffffffffull;
     208        INIT_LIST_HEAD(&pcidev->dev.devres_head);
    207209
    208210        // Subsystem ID
     
    800802}
    801803
    802 /**
    803  */
    804 void pci_set_driver_data (struct pci_dev *dev, void *driver_data)
    805 {
    806   if (dev)
    807     dev->driver_data = driver_data;
    808 }
    809 
    810 /**
    811  */
    812 void *pci_get_driver_data (struct pci_dev *dev)
    813 {
    814   if (dev)
    815     return dev->driver_data;
    816   return 0;
    817 }
    818804
    819805/**
     
    10381024}
    10391025
    1040 struct pci_driver_mapping {
    1041   struct pci_dev *dev;
    1042   struct pci_driver *drv;
    1043   unsigned long dma_mask;
    1044   void *driver_data;
    1045   u32 saved_config[16];
    1046 };
    1047 
    1048 #define PCI_MAX_MAPPINGS 64
    1049 static struct pci_driver_mapping drvmap [PCI_MAX_MAPPINGS] = { { NULL, } , };
    1050 
    1051 
    1052 static struct pci_driver_mapping *get_pci_driver_mapping(struct pci_dev *dev)
    1053 {
    1054   int i;
    1055 
    1056   for (i = 0; i < PCI_MAX_MAPPINGS; i++)
    1057     if (drvmap[i].dev == dev)
    1058       return &drvmap[i];
    1059   return NULL;
    1060 }
    1061 
    1062 struct pci_driver *snd_pci_compat_get_pci_driver(struct pci_dev *dev)
    1063 {
    1064   struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
    1065   if (map)
    1066     return map->drv;
    1067   return NULL;
    1068 }
    1069 #if 0
    1070 void * pci_get_drvdata (struct pci_dev *dev)
    1071 {
    1072   struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
    1073   if (map)
    1074     return map->driver_data;
    1075   return NULL;
    1076 }
    1077 
    1078 
    1079 void pci_set_drvdata (struct pci_dev *dev, void *driver_data)
    1080 {
    1081   struct pci_driver_mapping *map = get_pci_driver_mapping(dev);
    1082   if (map)
    1083     map->driver_data = driver_data;
    1084 }
    1085 #endif
    1086 
    1087 
    10881026//******************************************************************************
    10891027//******************************************************************************
     
    11801118}
    11811119
     1120struct region_devres {
     1121        struct resource *parent;
     1122        resource_size_t start;
     1123        resource_size_t n;
     1124};
     1125
     1126static void devm_region_release(struct device *dev, void *res)
     1127{
     1128        struct region_devres *this = res;
     1129
     1130        __release_region(this->parent, this->start, this->n);
     1131}
     1132
     1133struct resource *
     1134__devm_request_region(struct device *dev, struct resource *parent,
     1135                      resource_size_t start, resource_size_t n, const char *name)
     1136{
     1137        struct region_devres *dr = NULL;
     1138        struct resource *res;
     1139
     1140        dr = devres_alloc(devm_region_release, sizeof(struct region_devres),
     1141                          GFP_KERNEL);
     1142        if (!dr)
     1143                return NULL;
     1144
     1145        dr->parent = parent;
     1146        dr->start = start;
     1147        dr->n = n;
     1148
     1149        res = __request_region(parent, start, n, name);
     1150        if (res)
     1151                devres_add(dev, dr);
     1152        else
     1153                devres_free(dr);
     1154
     1155        return res;
     1156}
     1157EXPORT_SYMBOL(__devm_request_region);
     1158
     1159/*
     1160 * Managed PCI resources.  This manages device on/off, INTx/MSI/MSI-X
     1161 * on/off and BAR regions.  pci_dev itself records MSI/MSI-X status, so
     1162 * there's no need to track it separately.  pci_devres is initialized
     1163 * when a device is enabled using managed PCI device enable interface.
     1164 */
     1165struct pci_devres {
     1166        unsigned int enabled:1;
     1167        unsigned int pinned:1;
     1168        unsigned int orig_intx:1;
     1169        unsigned int restore_intx:1;
     1170        unsigned int mwi:1;
     1171        u32 region_mask;
     1172};
     1173
     1174static void pcim_release(struct device *gendev, void *res)
     1175{
     1176}
     1177
     1178static struct pci_devres *find_pci_dr(struct pci_dev *pdev)
     1179{
     1180        if (pci_is_managed(pdev))
     1181                return devres_find(&pdev->dev, pcim_release, NULL, NULL);
     1182        return NULL;
     1183}
     1184
     1185/**
     1186 * pci_intx - enables/disables PCI INTx for device dev
     1187 * @pdev: the PCI device to operate on
     1188 * @enable: boolean: whether to enable or disable PCI INTx
     1189 *
     1190 * Enables/disables PCI INTx for device @pdev
     1191 */
     1192void pci_intx(struct pci_dev *pdev, int enable)
     1193{
     1194        u16 pci_command, new;
     1195
     1196        pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
     1197
     1198        if (enable)
     1199                new = pci_command & ~PCI_COMMAND_INTX_DISABLE;
     1200        else
     1201                new = pci_command | PCI_COMMAND_INTX_DISABLE;
     1202
     1203        if (new != pci_command) {
     1204                struct pci_devres *dr;
     1205
     1206                pci_write_config_word(pdev, PCI_COMMAND, new);
     1207
     1208                dr = find_pci_dr(pdev);
     1209                if (dr && !dr->restore_intx) {
     1210                        dr->restore_intx = 1;
     1211                        dr->orig_intx = !enable;
     1212                }
     1213        }
     1214}
     1215EXPORT_SYMBOL_GPL(pci_intx);
  • GPL/trunk/lib32/regcache-rbtree.c

    r679 r772  
    170170                average = 0;
    171171
    172         seq_printf(s, "%d nodes, %d registers, average %d registers, used %zu bytes\n",
     172        seq_printf(s, "%d nodes, %d registers, average %d registers, used %lu bytes\n",
    173173                   nodes, registers, average, mem_size);
    174174
  • GPL/trunk/lib32/regcache.c

    r679 r772  
    2424static const struct regcache_ops *cache_types[] = {
    2525        &regcache_rbtree_ops,
    26 #if IS_ENABLED(CONFIG_REGCACHE_COMPRESSED)
    27         &regcache_lzo_ops,
     26#ifndef TARGET_OS2 // Not (yet?) supported
     27        &regcache_maple_ops,
    2828#endif
    2929        &regcache_flat_ops,
     
    562562EXPORT_SYMBOL_GPL(regcache_cache_bypass);
    563563
     564/**
     565 * regcache_reg_cached - Check if a register is cached
     566 *
     567 * @map: map to check
     568 * @reg: register to check
     569 *
     570 * Reports if a register is cached.
     571 */
     572bool regcache_reg_cached(struct regmap *map, unsigned int reg)
     573{
     574        unsigned int val;
     575        int ret;
     576
     577        map->lock(map->lock_arg);
     578
     579        ret = regcache_read(map, reg, &val);
     580
     581        map->unlock(map->lock_arg);
     582
     583        return ret == 0;
     584}
     585EXPORT_SYMBOL_GPL(regcache_reg_cached);
     586
    564587bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
    565588                      unsigned int val)
     
    729752        count = (cur - base) / map->reg_stride;
    730753
    731         dev_dbg(map->dev, "Writing %zu bytes for %d registers from 0x%x-0x%x\n",
     754        dev_dbg(map->dev, "Writing %lu bytes for %d registers from 0x%x-0x%x\n",
    732755                count * val_bytes, count, base, cur - map->reg_stride);
    733756
  • GPL/trunk/lib32/regmap.c

    r679 r772  
    652652                return ret;
    653653
     654        regmap_debugfs_exit(map);
    654655        regmap_debugfs_init(map);
    655656
     
    17311732                /* If the write goes beyond the end of the window split it */
    17321733                while (val_num > win_residue) {
    1733                         dev_dbg(map->dev, "Writing window %d/%zu\n",
     1734                        dev_dbg(map->dev, "Writing window %d/%lu\n",
    17341735                                win_residue, val_len / map->format.val_bytes);
    17351736                        ret = _regmap_raw_write_impl(map, reg, val,
  • GPL/trunk/lib32/soundmixer.c

    r679 r772  
    409409      idxMute = pHandle->controls[OSS_MIXER_FRONT].idxMute;
    410410    }
    411     /* HDA codecs workaround from Andy */
    412     if (idx == -1)
    413     {
    414       idx = pHandle->controls[OSS_MIXER_SPEAKER].idxVolume;
    415       idxMute = pHandle->controls[OSS_MIXER_SPEAKER].idxMute;
    416     }
    417     /* HDA codecs workaround from Andy */
    418411    break;
    419412  case OSS32_MIX_VOLUME_MIDI:
  • GPL/trunk/lib32/vsprintf.c

    r32 r772  
    3232
    3333#include <stdarg.h>
    34 
     34#include <linux/kernel.h>
    3535
    3636
     
    366366}
    367367
     368/**
     369 * vscnprintf - Format a string and place it in a buffer
     370 * @buf: The buffer to place the result into
     371 * @size: The size of the buffer, including the trailing null space
     372 * @fmt: The format string to use
     373 * @args: Arguments for the format string
     374 *
     375 * The return value is the number of characters which have been written into
     376 * the @buf not including the trailing '\0'. If @size is == 0 the function
     377 * returns 0.
     378 *
     379 * If you're not already dealing with a va_list consider using scnprintf().
     380 *
     381 * See the vsnprintf() documentation for format string extensions over C99.
     382 */
     383int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
     384{
     385        int i;
     386
     387        if (unlikely(!size))
     388                return 0;
     389
     390        i = vsnprintf(buf, size, fmt, args);
     391
     392        if (likely(i < size))
     393                return i;
     394
     395        return size - 1;
     396}
Note: See TracChangeset for help on using the changeset viewer.