Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED, USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28E10C43381 for ; Fri, 15 Feb 2019 19:40:40 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4D6C222A1 for ; Fri, 15 Feb 2019 19:40:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FNzVXYrp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4D6C222A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1gujLP-0003cu-8h; Fri, 15 Feb 2019 14:40:19 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1gujLB-0003cj-Bn for kernelnewbies@kernelnewbies.org; Fri, 15 Feb 2019 14:40:05 -0500 Received: by mail-wm1-x344.google.com with SMTP id y185so7377267wmd.1 for ; Fri, 15 Feb 2019 11:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=YiznpDx+5xCItUsEt1Oe6ZvBpxB7NkcQ/zgePBKuvnE=; b=FNzVXYrpRAavp9McCuXObyEU8hQ6wGv3aSOgWG+Zuj2v839qE2utu7pqs3lPNQwUfH AmZ0REYpQwbnngc4eCh7HBGhSMcQIooFrGAdy1gQC97yFjKjbb6zPjBMw7PWcbpJ7cCv uNR8YdqGuv+aGze7qE+H6iOYLaMBcT4Kci1VzoryLU4X/jKlWXZxoVQcEys0bgMJJiBM wACzVAeVHYnlHLQp+avP+Nt244nuSja3XKCU8jxjbiGbO8oH/A7uTjjb0dLZ+3eW4Vse k6Pxd9haGLVSP9d+8mYcSIN3FNbSAuEnTaHMYbbrP6bUitNLVmETyynPa/dYo4qlO6nq /0yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=YiznpDx+5xCItUsEt1Oe6ZvBpxB7NkcQ/zgePBKuvnE=; b=TvQZpADaFHNLUnxCOoL0SHxIRUftUhfh9slT/dI1M6Ont2nFjtJL0WFtdGzp7DKA53 u74Zx9GKJk0hoXdqjPXTo4CbVlHDsAM0iAK1tPNOH/2PLz2E7zRnp0JiTHmb6P0zh8k7 G0OdiFXWVVOXZwDPt9NZ7ZWeq2VY0UNs//tPU19nqU+ly4IN4mcnWdkxnj8wksdc/J71 erBmLEf9GP/w0DkUUQJaxD68CrMeMRam2OCso9B/g9BonrND4HwmnRt4YaPHYH6Zlji7 w49C0ssEAknq1xvnEXYJcUHFhHlNpLtzh2Gjqc7xcrbLwsBxujLZyr0p4SU/Ug+EW6O7 TWuw== X-Gm-Message-State: AHQUAuawPqiJyZwqnvOQjd+Dz3UdK68vSQNC9BTauHr6sZ3nQj80pm5h x+m8JOUq4520+7Z6Fr0dV4DuNDS7 X-Google-Smtp-Source: AHgI3IbS56Us55wU7/xBb2PT+Y2e5pD2r9MLD4gePx0b2Wt3Eb4ymekrvn1vbB+84Kp/AwOqPMcJgA== X-Received: by 2002:a1c:f312:: with SMTP id q18mr7586120wmq.106.1550259542645; Fri, 15 Feb 2019 11:39:02 -0800 (PST) Received: from raspberrypi ([2a00:23c4:9128:9601:b581:ffdb:2069:2f0a]) by smtp.gmail.com with ESMTPSA id g202sm1461440wme.26.2019.02.15.11.39.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Feb 2019 11:39:01 -0800 (PST) Date: Fri, 15 Feb 2019 19:38:59 +0000 From: Laurence Rochfort To: kernelnewbies@kernelnewbies.org Subject: Platform driver probe() not being called when device-tree overlaid Message-ID: <20190215193859.53p6u32ds3ihd47i@raspberrypi> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Cc: laurence.rochfort@gmail.com X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Hi all, I'm attempting to write a platform device driver that gets loaded when a compatible device-tree overlay is loaded by dtoverlay. This is just a learning exercise at the moment, so I'm trying to write the simplest platform device I can, rather than extending one of the device drivers that extend platform device (terminology?). I'm trying to get just enough to get the driver's probe() function called when the device-tree overlay is applied, and then create a misc device. My module seems to init just fine, and the device-tree overlay seems to also load without issue, but for some reason probe() is never called. Am I correct in using probe() with platform devices? I understand platform devices can't be enumerated/detected, but I thought that probe() would be called when there was a compatibility match between the driver and the device-tree overlay. Any pointers would be much appreciated. Cheers, Laurence. Here's what /sys shows: $ cat /sys/devices/platform/gde060f3/uevent OF_NAME=gde060f3 OF_FULLNAME=/gde060f3 OF_COMPATIBLE_0=gde060f3 OF_COMPATIBLE_N=1 MODALIAS=of:Ngde060f3TCgde060f3 $ cat /sys/firmware/devicetree/base/gde060f3/compatible gde060f3 $ cat /sys/firmware/devicetree/base/gde060f3/name gde060f3 $ cat /sys/firmware/devicetree/base/gde060f3/status okay Here's the loaded device-tree: $ dtc -I fs /proc/device-tree /dts-v1/; / { compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837"; serial-number = "00000000427625f0"; model = "Raspberry Pi 3 Model B Plus Rev 1.3"; memreserve = <0x3b400000 0x4c00000>; interrupt-parent = <0x1>; #address-cells = <0x1>; #size-cells = <0x1>; clocks { *** SNIPPED *** }; __overrides__ { *** SNIPPED *** }; gde060f3 { compatible = "gde060f3"; status = "okay"; phandle = <0x7b>; linux,phandle = <0x7b>; }; system { linux,serial = <0x0 0x427625f0>; linux,revision = <0xa020d3>; }; *** SNIPPED *** }; module file: #define DEBUG #include #include #include #include #include #include #include struct gde060f3_struct { struct platform_device *pdev; struct miscdevice mdev; }; static inline struct gde060f3_struct *to_gde060f3_struct(struct file *file) { struct miscdevice *miscdev = file->private_data; return container_of(miscdev, struct gde060f3_struct, mdev); } static ssize_t gde060f3_read(struct file *file, char __user *buf, size_t count, loff_t *pos) { struct gde060f3_struct *gde060f3 = to_gde060f3_struct(file); /* just for example */ (void)gde060f3; /* unused */ return simple_read_from_buffer(buf, count, pos, "gde060f3 text", 14); } static const struct file_operations gde060f3_fops = { .owner = THIS_MODULE, .read = gde060f3_read, }; static const struct of_device_id gde060f3_match[] = { { .compatible = "gde060f3" }, {}, }; MODULE_DEVICE_TABLE(of, gde060f3_match); static int gde060f3_probe(struct platform_device *pdev) { struct gde060f3_struct *gde060f3; int ret; pr_info("gde060f3_probe()\n"); gde060f3 = kmalloc(sizeof(*gde060f3), GFP_KERNEL); if (!gde060f3) return -ENOMEM; platform_set_drvdata(pdev, gde060f3); gde060f3->pdev = pdev; gde060f3->mdev.minor = MISC_DYNAMIC_MINOR; gde060f3->mdev.name = "gde060f3"; gde060f3->mdev.fops = &gde060f3_fops; gde060f3->mdev.parent = NULL; ret = misc_register(&gde060f3->mdev); if (ret) { dev_err(&pdev->dev, "Failed to register miscdev\n"); return ret; } dev_info(&pdev->dev, "Registered\n"); pr_info("Registered\n"); return 0; } static int gde060f3_remove(struct platform_device *pdev) { struct gde060f3_struct *gde060f3 = platform_get_drvdata(pdev); misc_deregister(&gde060f3->mdev); kfree(gde060f3); dev_info(&pdev->dev, "Unregistered\n"); pr_info("Unregistered\n"); return 0; } static struct platform_driver gde060f3_driver = { .probe = gde060f3_probe, .remove = gde060f3_remove, .driver = { .name = "gde060f3", .of_match_table = gde060f3_match, }, }; module_platform_driver_probe(gde060f3_driver, gde060f3_probe); MODULE_AUTHOR("Laurence Rochfort "); MODULE_DESCRIPTION("GPIO driver for Good Display GDE060F3 ePaper Display"); MODULE_LICENSE("GPL"); overlay file: /dts-v1/; /plugin/; / { compatible = "brcm,bcm2708"; fragment@0 { // target or target-path? target-path = "/"; __overlay__ { gde060f3: gde060f3 { compatible = "gde060f3"; status = "okay"; }; }; }; }; _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies