Changeset 772 for GPL/trunk/lib32/pci.c


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

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

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • 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);
Note: See TracChangeset for help on using the changeset viewer.