···747747 return 0;748748}749749750750+static int cti_pm_setup(struct cti_drvdata *drvdata)751751+{752752+ int ret;753753+754754+ if (drvdata->ctidev.cpu == -1)755755+ return 0;756756+757757+ if (nr_cti_cpu)758758+ goto done;759759+760760+ cpus_read_lock();761761+ ret = cpuhp_setup_state_nocalls_cpuslocked(762762+ CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,763763+ "arm/coresight_cti:starting",764764+ cti_starting_cpu, cti_dying_cpu);765765+ if (ret) {766766+ cpus_read_unlock();767767+ return ret;768768+ }769769+770770+ ret = cpu_pm_register_notifier(&cti_cpu_pm_nb);771771+ cpus_read_unlock();772772+ if (ret) {773773+ cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);774774+ return ret;775775+ }776776+777777+done:778778+ nr_cti_cpu++;779779+ cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;780780+781781+ return 0;782782+}783783+750784/* release PM registrations */751785static void cti_pm_release(struct cti_drvdata *drvdata)752786{753753- if (drvdata->ctidev.cpu >= 0) {754754- if (--nr_cti_cpu == 0) {755755- cpu_pm_unregister_notifier(&cti_cpu_pm_nb);787787+ if (drvdata->ctidev.cpu == -1)788788+ return;756789757757- cpuhp_remove_state_nocalls(758758- CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);759759- }760760- cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;790790+ cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;791791+ if (--nr_cti_cpu == 0) {792792+ cpu_pm_unregister_notifier(&cti_cpu_pm_nb);793793+ cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);761794 }762795}763796···856823857824 /* driver data*/858825 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);859859- if (!drvdata) {860860- ret = -ENOMEM;861861- dev_info(dev, "%s, mem err\n", __func__);862862- goto err_out;863863- }826826+ if (!drvdata)827827+ return -ENOMEM;864828865829 /* Validity for the resource is already checked by the AMBA core */866830 base = devm_ioremap_resource(dev, res);867867- if (IS_ERR(base)) {868868- ret = PTR_ERR(base);869869- dev_err(dev, "%s, remap err\n", __func__);870870- goto err_out;871871- }831831+ if (IS_ERR(base))832832+ return PTR_ERR(base);833833+872834 drvdata->base = base;873835874836 dev_set_drvdata(dev, drvdata);···882854 pdata = coresight_cti_get_platform_data(dev);883855 if (IS_ERR(pdata)) {884856 dev_err(dev, "coresight_cti_get_platform_data err\n");885885- ret = PTR_ERR(pdata);886886- goto err_out;857857+ return PTR_ERR(pdata);887858 }888859889860 /* default to powered - could change on PM notifications */···894867 drvdata->ctidev.cpu);895868 else896869 cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev);897897- if (!cti_desc.name) {898898- ret = -ENOMEM;899899- goto err_out;900900- }870870+ if (!cti_desc.name)871871+ return -ENOMEM;901872902873 /* setup CPU power management handling for CPU bound CTI devices. */903903- if (drvdata->ctidev.cpu >= 0) {904904- cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;905905- if (!nr_cti_cpu++) {906906- cpus_read_lock();907907- ret = cpuhp_setup_state_nocalls_cpuslocked(908908- CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,909909- "arm/coresight_cti:starting",910910- cti_starting_cpu, cti_dying_cpu);911911-912912- if (!ret)913913- ret = cpu_pm_register_notifier(&cti_cpu_pm_nb);914914- cpus_read_unlock();915915- if (ret)916916- goto err_out;917917- }918918- }874874+ ret = cti_pm_setup(drvdata);875875+ if (ret)876876+ return ret;919877920878 /* create dynamic attributes for connections */921879 ret = cti_create_cons_sysfs(dev, drvdata);922880 if (ret) {923881 dev_err(dev, "%s: create dynamic sysfs entries failed\n",924882 cti_desc.name);925925- goto err_out;883883+ goto pm_release;926884 }927885928886 /* set up coresight component description */···920908 drvdata->csdev = coresight_register(&cti_desc);921909 if (IS_ERR(drvdata->csdev)) {922910 ret = PTR_ERR(drvdata->csdev);923923- goto err_out;911911+ goto pm_release;924912 }925913926914 /* add to list of CTI devices */···939927 dev_info(&drvdata->csdev->dev, "CTI initialized\n");940928 return 0;941929942942-err_out:930930+pm_release:943931 cti_pm_release(drvdata);944932 return ret;945933}
+54-30
drivers/hwtracing/coresight/coresight-etm4x.c
···13881388 .notifier_call = etm4_cpu_pm_notify,13891389};1390139013911391-static int etm4_cpu_pm_register(void)13911391+/* Setup PM. Called with cpus locked. Deals with error conditions and counts */13921392+static int etm4_pm_setup_cpuslocked(void)13921393{13931393- if (IS_ENABLED(CONFIG_CPU_PM))13941394- return cpu_pm_register_notifier(&etm4_cpu_pm_nb);13941394+ int ret;1395139513961396- return 0;13961396+ if (etm4_count++)13971397+ return 0;13981398+13991399+ ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);14001400+ if (ret)14011401+ goto reduce_count;14021402+14031403+ ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,14041404+ "arm/coresight4:starting",14051405+ etm4_starting_cpu, etm4_dying_cpu);14061406+14071407+ if (ret)14081408+ goto unregister_notifier;14091409+14101410+ ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,14111411+ "arm/coresight4:online",14121412+ etm4_online_cpu, NULL);14131413+14141414+ /* HP dyn state ID returned in ret on success */14151415+ if (ret > 0) {14161416+ hp_online = ret;14171417+ return 0;14181418+ }14191419+14201420+ /* failed dyn state - remove others */14211421+ cpuhp_remove_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING);14221422+14231423+unregister_notifier:14241424+ cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);14251425+14261426+reduce_count:14271427+ --etm4_count;14281428+ return ret;13971429}1398143013991399-static void etm4_cpu_pm_unregister(void)14311431+static void etm4_pm_clear(void)14001432{14011401- if (IS_ENABLED(CONFIG_CPU_PM))14021402- cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);14331433+ if (--etm4_count != 0)14341434+ return;14351435+14361436+ cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);14371437+ cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);14381438+ if (hp_online) {14391439+ cpuhp_remove_state_nocalls(hp_online);14401440+ hp_online = 0;14411441+ }14031442}1404144314051444static int etm4_probe(struct amba_device *adev, const struct amba_id *id)···14921453 etm4_init_arch_data, drvdata, 1))14931454 dev_err(dev, "ETM arch init failed\n");1494145514951495- if (!etm4_count++) {14961496- cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,14971497- "arm/coresight4:starting",14981498- etm4_starting_cpu, etm4_dying_cpu);14991499- ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,15001500- "arm/coresight4:online",15011501- etm4_online_cpu, NULL);15021502- if (ret < 0)15031503- goto err_arch_supported;15041504- hp_online = ret;15051505-15061506- ret = etm4_cpu_pm_register();15071507- if (ret)15081508- goto err_arch_supported;15091509- }15101510-14561456+ ret = etm4_pm_setup_cpuslocked();15111457 cpus_read_unlock();14581458+14591459+ /* etm4_pm_setup_cpuslocked() does its own cleanup - exit on error */14601460+ if (ret) {14611461+ etmdrvdata[drvdata->cpu] = NULL;14621462+ return ret;14631463+ }1512146415131465 if (etm4_arch_supported(drvdata->arch) == false) {15141466 ret = -EINVAL;···1547151715481518err_arch_supported:15491519 etmdrvdata[drvdata->cpu] = NULL;15501550- if (--etm4_count == 0) {15511551- etm4_cpu_pm_unregister();15521552-15531553- cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);15541554- if (hp_online)15551555- cpuhp_remove_state_nocalls(hp_online);15561556- }15201520+ etm4_pm_clear();15571521 return ret;15581522}15591523
+12-12
drivers/misc/atmel-ssc.c
···1010#include <linux/clk.h>1111#include <linux/err.h>1212#include <linux/io.h>1313-#include <linux/spinlock.h>1313+#include <linux/mutex.h>1414#include <linux/atmel-ssc.h>1515#include <linux/slab.h>1616#include <linux/module.h>···2020#include "../../sound/soc/atmel/atmel_ssc_dai.h"21212222/* Serialize access to ssc_list and user count */2323-static DEFINE_SPINLOCK(user_lock);2323+static DEFINE_MUTEX(user_lock);2424static LIST_HEAD(ssc_list);25252626struct ssc_device *ssc_request(unsigned int ssc_num)···2828 int ssc_valid = 0;2929 struct ssc_device *ssc;30303131- spin_lock(&user_lock);3131+ mutex_lock(&user_lock);3232 list_for_each_entry(ssc, &ssc_list, list) {3333 if (ssc->pdev->dev.of_node) {3434 if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")···4444 }45454646 if (!ssc_valid) {4747- spin_unlock(&user_lock);4747+ mutex_unlock(&user_lock);4848 pr_err("ssc: ssc%d platform device is missing\n", ssc_num);4949 return ERR_PTR(-ENODEV);5050 }51515252 if (ssc->user) {5353- spin_unlock(&user_lock);5353+ mutex_unlock(&user_lock);5454 dev_dbg(&ssc->pdev->dev, "module busy\n");5555 return ERR_PTR(-EBUSY);5656 }5757 ssc->user++;5858- spin_unlock(&user_lock);5858+ mutex_unlock(&user_lock);59596060 clk_prepare(ssc->clk);6161···6767{6868 bool disable_clk = true;69697070- spin_lock(&user_lock);7070+ mutex_lock(&user_lock);7171 if (ssc->user)7272 ssc->user--;7373 else {7474 disable_clk = false;7575 dev_dbg(&ssc->pdev->dev, "device already free\n");7676 }7777- spin_unlock(&user_lock);7777+ mutex_unlock(&user_lock);78787979 if (disable_clk)8080 clk_unprepare(ssc->clk);···237237 return -ENXIO;238238 }239239240240- spin_lock(&user_lock);240240+ mutex_lock(&user_lock);241241 list_add_tail(&ssc->list, &ssc_list);242242- spin_unlock(&user_lock);242242+ mutex_unlock(&user_lock);243243244244 platform_set_drvdata(pdev, ssc);245245···258258259259 ssc_sound_dai_remove(ssc);260260261261- spin_lock(&user_lock);261261+ mutex_lock(&user_lock);262262 list_del(&ssc->list);263263- spin_unlock(&user_lock);263263+ mutex_unlock(&user_lock);264264265265 return 0;266266}
···930930931931 /* TODO: Read supported rates/formats from hardware */932932 for (i = off; i < (off + num); i++) {933933- dais[i].name = kasprintf(GFP_KERNEL, "SDW%d Pin%d",934934- cdns->instance, i);933933+ dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL,934934+ "SDW%d Pin%d",935935+ cdns->instance, i);935936 if (!dais[i].name)936937 return -ENOMEM;937938
+2-2
drivers/uio/uio_pdrv_genirq.c
···160160 priv->pdev = pdev;161161162162 if (!uioinfo->irq) {163163- ret = platform_get_irq(pdev, 0);163163+ ret = platform_get_irq_optional(pdev, 0);164164 uioinfo->irq = ret;165165- if (ret == -ENXIO && pdev->dev.of_node)165165+ if (ret == -ENXIO)166166 uioinfo->irq = UIO_IRQ_NONE;167167 else if (ret == -EPROBE_DEFER)168168 return ret;
+4-2
drivers/virt/vboxguest/vboxguest_core.c
···14441444 or_mask = caps->u.in.or_mask;14451445 not_mask = caps->u.in.not_mask;1446144614471447- if ((or_mask | not_mask) & ~VMMDEV_EVENT_VALID_EVENT_MASK)14471447+ if ((or_mask | not_mask) & ~VMMDEV_GUEST_CAPABILITIES_MASK)14481448 return -EINVAL;1449144914501450 ret = vbg_set_session_capabilities(gdev, session, or_mask, not_mask,···1520152015211521 /* For VMMDEV_REQUEST hdr->type != VBG_IOCTL_HDR_TYPE_DEFAULT */15221522 if (req_no_size == VBG_IOCTL_VMMDEV_REQUEST(0) ||15231523- req == VBG_IOCTL_VMMDEV_REQUEST_BIG)15231523+ req == VBG_IOCTL_VMMDEV_REQUEST_BIG ||15241524+ req == VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT)15241525 return vbg_ioctl_vmmrequest(gdev, session, data);1525152615261527 if (hdr->type != VBG_IOCTL_HDR_TYPE_DEFAULT)···15591558 case VBG_IOCTL_HGCM_CALL(0):15601559 return vbg_ioctl_hgcm_call(gdev, session, f32bit, data);15611560 case VBG_IOCTL_LOG(0):15611561+ case VBG_IOCTL_LOG_ALT(0):15621562 return vbg_ioctl_log(data);15631563 }15641564
+15
drivers/virt/vboxguest/vboxguest_core.h
···1515#include <linux/vboxguest.h>1616#include "vmmdev.h"17171818+/*1919+ * The mainline kernel version (this version) of the vboxguest module2020+ * contained a bug where it defined VBGL_IOCTL_VMMDEV_REQUEST_BIG and2121+ * VBGL_IOCTL_LOG using _IOC(_IOC_READ | _IOC_WRITE, 'V', ...) instead2222+ * of _IO(V, ...) as the out of tree VirtualBox upstream version does.2323+ *2424+ * These _ALT definitions keep compatibility with the wrong defines the2525+ * mainline kernel version used for a while.2626+ * Note the VirtualBox userspace bits have always been built against2727+ * VirtualBox upstream's headers, so this is likely not necessary. But2828+ * we must never break our ABI so we keep these around to be 100% sure.2929+ */3030+#define VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)3131+#define VBG_IOCTL_LOG_ALT(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)3232+1833struct vbg_session;19342035/** VBox guest memory balloon. */
+2-1
drivers/virt/vboxguest/vboxguest_linux.c
···131131 * the need for a bounce-buffer and another copy later on.132132 */133133 is_vmmdev_req = (req & ~IOCSIZE_MASK) == VBG_IOCTL_VMMDEV_REQUEST(0) ||134134- req == VBG_IOCTL_VMMDEV_REQUEST_BIG;134134+ req == VBG_IOCTL_VMMDEV_REQUEST_BIG ||135135+ req == VBG_IOCTL_VMMDEV_REQUEST_BIG_ALT;135136136137 if (is_vmmdev_req)137138 buf = vbg_req_alloc(size, VBG_IOCTL_HDR_TYPE_DEFAULT,
+2
drivers/virt/vboxguest/vmmdev.h
···206206 * not.207207 */208208#define VMMDEV_GUEST_SUPPORTS_GRAPHICS BIT(2)209209+/* The mask of valid capabilities, for sanity checking. */210210+#define VMMDEV_GUEST_CAPABILITIES_MASK 0x00000007U209211210212/** struct vmmdev_hypervisorinfo - Hypervisor info structure. */211213struct vmmdev_hypervisorinfo {
+2-2
include/uapi/linux/vboxguest.h
···103103104104105105/* IOCTL to perform a VMM Device request larger then 1KB. */106106-#define VBG_IOCTL_VMMDEV_REQUEST_BIG _IOC(_IOC_READ | _IOC_WRITE, 'V', 3, 0)106106+#define VBG_IOCTL_VMMDEV_REQUEST_BIG _IO('V', 3)107107108108109109/** VBG_IOCTL_HGCM_CONNECT data structure. */···198198 } u;199199};200200201201-#define VBG_IOCTL_LOG(s) _IOC(_IOC_READ | _IOC_WRITE, 'V', 9, s)201201+#define VBG_IOCTL_LOG(s) _IO('V', 9)202202203203204204/** VBG_IOCTL_WAIT_FOR_EVENTS data structure. */