{"id":263059,"date":"2015-08-06T17:12:02","date_gmt":"2015-08-06T13:12:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263059"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263059","title":{"rendered":"\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u0434 \u0447\u0438\u0449\u0435: \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PCI \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 NAND Denali"},"content":{"rendered":"<p>     \t\u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PCI \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 NAND Denali \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u0435\u0436\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u044f\u0434\u0440\u0430 Linux. <a name=\"habracut\"><\/a><\/p>\n<p>  \u042d\u0442\u043e\u0442 \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u0440\u044f\u0434\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c. \u0421\u0430\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <i>drivers\/mtd\/nand\/denali_pci.c<\/i>.<\/p>\n<h2><font color=\"blue\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 Kconfig<\/font><\/h2>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043a\u043e\u0441\u043d\u0451\u043c\u0441\u044f Kconfig. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0442 \u043f\u043e \u0443\u0436\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c + \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0430 \u0448\u0438\u043d\u0435, \u0441\u043b\u0435\u0434\u0443\u044f \u043b\u043e\u0433\u0438\u043a\u0435 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 <a href=\"https:\/\/lkml.org\/lkml\/2015\/4\/21\/654\">\u0441\u0430\u043c\u043e\u0433\u043e \u0422\u043e\u0440\u0432\u0430\u043b\u044c\u0434\u0441\u0430<\/a>) \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u0440\u044b\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u043e\u043f\u0443\u0442\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u043d\u0430 \u0442\u0430\u0431\u0443\u043b\u044f\u0446\u0438\u0438 \u0432 \u0442\u0435\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c.<\/p>\n<p>  <a href=\"http:\/\/lists.infradead.org\/pipermail\/linux-mtd\/2015-August\/060851.html\">\u0414\u0435\u043b\u0430\u0439 \u0440\u0430\u0437!<\/a><\/p>\n<h2><font color=\"blue\">\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432<\/font><\/h2>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 <code>module_pci_driver()<\/code>:  <\/p>\n<pre><code class=\"diff\">--- a\/drivers\/mtd\/nand\/denali_pci.c +++ b\/drivers\/mtd\/nand\/denali_pci.c @@ -129,14 +129,4 @@ static struct pci_driver denali_pci_driver = {         .remove = denali_pci_remove,  };   -static int denali_init_pci(void) -{ -       return pci_register_driver(&denali_pci_driver); -} -module_init(denali_init_pci); - -static void denali_exit_pci(void) -{ -       pci_unregister_driver(&denali_pci_driver); -} -module_exit(denali_exit_pci); +module_pci_driver(denali_pci_driver); <\/code><\/pre>\n<p>  <a href=\"http:\/\/lists.infradead.org\/pipermail\/linux-mtd\/2015-August\/060850.html\">\u0414\u0435\u043b\u0430\u0439 \u0434\u0432\u0430!<\/a><\/p>\n<h2><font color=\"blue\">\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 API \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/font><\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443, \u0437\u0430\u043c\u0435\u043d\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b (\u0432\u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/post\/255459\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b \u0438\u0445).<\/p>\n<p>  \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e, <code>devm_kzalloc()<\/code>:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">--- a\/drivers\/mtd\/nand\/denali_pci.c +++ b\/drivers\/mtd\/nand\/denali_pci.c @@ -35,14 +35,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)         unsigned long csr_len, mem_len;         struct denali_nand_info *denali;  -       denali = kzalloc(sizeof(*denali), GFP_KERNEL); +       denali = devm_kzalloc(&dev-&gt;dev, sizeof(*denali), GFP_KERNEL);         if (!denali)                 return -ENOMEM;          ret = pci_enable_device(dev);         if (ret) {                 pr_err(&quot;Spectra: pci_enable_device failed.\\n&quot;); -               goto failed_alloc_memery; +               return ret;         }          if (id-&gt;driver_data == INTEL_CE4100) { @@ -103,9 +103,6 @@ failed_req_regions:         pci_release_regions(dev);  failed_enable_dev:         pci_disable_device(dev); -failed_alloc_memery: -       kfree(denali); -         return ret;  }  @@ -119,7 +116,6 @@ static void denali_pci_remove(struct pci_dev *dev)         iounmap(denali-&gt;flash_mem);         pci_release_regions(dev);         pci_disable_device(dev); -       kfree(denali);  }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u043a \u0448\u0438\u043d\u0435 PCI, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f devres API \u0434\u043b\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 PCI:  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">--- a\/drivers\/mtd\/nand\/denali_pci.c +++ b\/drivers\/mtd\/nand\/denali_pci.c @@ -30,7 +30,7 @@ MODULE_DEVICE_TABLE(pci, denali_pci_ids);    static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)  { -       int ret = -ENODEV; +       int ret;         resource_size_t csr_base, mem_base;         unsigned long csr_len, mem_len;         struct denali_nand_info *denali; @@ -39,7 +39,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)         if (!denali)                 return -ENOMEM;   -       ret = pci_enable_device(dev); +       ret = pcim_enable_device(dev);         if (ret) {                 pr_err(&quot;Spectra: pci_enable_device failed.\\n&quot;);                 return ret; @@ -70,14 +70,13 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)         ret = pci_request_regions(dev, DENALI_NAND_NAME);         if (ret) {                 pr_err(&quot;Spectra: Unable to request memory regions\\n&quot;); -               goto failed_enable_dev; +               return ret;         }           denali-&gt;flash_reg = ioremap_nocache(csr_base, csr_len);         if (!denali-&gt;flash_reg) {                 pr_err(&quot;Spectra: Unable to remap memory region\\n&quot;); -               ret = -ENOMEM; -               goto failed_req_regions; +               return -ENOMEM;         }           denali-&gt;flash_mem = ioremap_nocache(mem_base, mem_len); @@ -99,10 +98,6 @@ failed_remap_mem:         iounmap(denali-&gt;flash_mem);  failed_remap_reg:         iounmap(denali-&gt;flash_reg); -failed_req_regions: -       pci_release_regions(dev); -failed_enable_dev: -       pci_disable_device(dev);         return ret;  }   @@ -114,8 +109,6 @@ static void denali_pci_remove(struct pci_dev *dev)         denali_remove(denali);         iounmap(denali-&gt;flash_reg);         iounmap(denali-&gt;flash_mem); -       pci_release_regions(dev); -       pci_disable_device(dev);  }   <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 <code>ioremap_nocache()<\/code> \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c, \u043d\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 (\u0434\u0430 \u0438 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043c\u0438\u0440\u0435 \u0441\u0435\u0433\u043e\u0434\u043d\u044f) \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 PCI BAR&#8217;\u0430\u0445.<\/p>\n<p>  \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435, \u0438 <a href=\"http:\/\/lists.infradead.org\/pipermail\/linux-mtd\/2015-August\/060848.html\">\u0434\u0435\u043b\u0430\u0439 \u0442\u0440\u0438!<\/a><\/p>\n<h2><font color=\"blue\">\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433<\/font><\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u043a\u0440\u0430\u0441\u043e\u0442\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c <code>pr_err()<\/code> \u043d\u0430 <code>dev_err()<\/code>:  <\/p>\n<pre><code class=\"diff\">--- a\/drivers\/mtd\/nand\/denali_pci.c +++ b\/drivers\/mtd\/nand\/denali_pci.c @@ -41,7 +41,7 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)           ret = pcim_enable_device(dev);         if (ret) { -               pr_err(&quot;Spectra: pci_enable_device failed.\\n&quot;); +               dev_err(&dev-&gt;dev, &quot;Spectra: pci_enable_device failed.\\n&quot;);                 return ret;         }   @@ -69,19 +69,19 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)           ret = pci_request_regions(dev, DENALI_NAND_NAME);         if (ret) { -               pr_err(&quot;Spectra: Unable to request memory regions\\n&quot;); +               dev_err(&dev-&gt;dev, &quot;Spectra: Unable to request memory regions\\n&quot;);                 return ret;         }           denali-&gt;flash_reg = ioremap_nocache(csr_base, csr_len);         if (!denali-&gt;flash_reg) { -               pr_err(&quot;Spectra: Unable to remap memory region\\n&quot;); +               dev_err(&dev-&gt;dev, &quot;Spectra: Unable to remap memory region\\n&quot;);                 return -ENOMEM;         }           denali-&gt;flash_mem = ioremap_nocache(mem_base, mem_len);         if (!denali-&gt;flash_mem) { -               pr_err(&quot;Spectra: ioremap_nocache failed!&quot;); +               dev_err(&dev-&gt;dev, &quot;Spectra: ioremap_nocache failed!&quot;);                 ret = -ENOMEM;                 goto failed_remap_reg;         } <\/code><\/pre>\n<p>  <a href=\"http:\/\/lists.infradead.org\/pipermail\/linux-mtd\/2015-August\/060849.html\">\u0414\u0435\u043b\u0430\u0439 \u0447\u0435\u0442\u044b\u0440\u0435!<\/a><\/p>\n<p>  \u041f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433\u0438:  <\/p>\n<pre><code class=\"diff\"> drivers\/mtd\/nand\/Kconfig      | 13 +++++--------  drivers\/mtd\/nand\/denali_pci.c | 43 +++++++++++--------------------------------  2 files changed, 16 insertions(+), 40 deletions(-) <\/code><\/pre>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u0430. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u044c\u0443\u043f\u043d\u044b\u0435 API \u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u043e\u0434\u0435!     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/264289\/\"> http:\/\/habrahabr.ru\/post\/264289\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 PCI \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 NAND Denali \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0434 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u043e\u0432, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u0435\u0436\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u044f\u0434\u0440\u0430 Linux. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-263059","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263059"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263059\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}