From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751380AbdAWOtB (ORCPT ); Mon, 23 Jan 2017 09:49:01 -0500 Received: from mga06.intel.com ([134.134.136.31]:2620 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751244AbdAWOtA (ORCPT ); Mon, 23 Jan 2017 09:49:00 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,274,1477983600"; d="scan'208";a="1116617515" Message-ID: <1485182933.2133.285.camel@linux.intel.com> Subject: Re: [char-misc-next] mei: simplify error handling via devres function. From: Andy Shevchenko To: "Winkler, Tomas" , Andy Shevchenko Cc: Greg Kroah-Hartman , "Usyskin, Alexander" , "linux-kernel@vger.kernel.org" Date: Mon, 23 Jan 2017 16:48:53 +0200 In-Reply-To: <5B8DA87D05A7694D9FA63FD143655C1B543802E4@hasmsx108.ger.corp.intel.com> References: <1484932972-3442-1-git-send-email-tomas.winkler@intel.com> <5B8DA87D05A7694D9FA63FD143655C1B543802E4@hasmsx108.ger.corp.intel.com> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.3-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2017-01-21 at 10:12 +0000, Winkler, Tomas wrote: > > > > > -struct mei_device *mei_txe_dev_init(struct pci_dev *pdev) > > > +struct mei_device *devm_mei_txe_init(struct pci_dev *pdev) > > > > Ditto. > > > > >  end: > > > +       pci_set_drvdata(pdev, NULL); > > > > Not needed. > > Please explain, we rely on pci_get_drvdata() returning NULL when > unregistered.  PCI core will take care about this one. Actually device core for any of user of struct device. See __device_release_driver() for the details. > > > > > -       free_irq(pdev->irq, dev); > > > +       devm_free_irq(&pdev->dev, pdev->irq, dev); > > >         pci_disable_msi(pdev); > > > > All three not needed > > I believe we need it on suspend as we are going over  irq request > again in resume.  Please provide more info you if you still insist.  Ah, sorry, I missed that these are suspend/resume hooks. So, Can you elaborate a bit why you need to disable interrupts during system suspend? (Basically in this case better not to use devm_request_*irq() at all) > > > > >         return 0; > > > @@ -75,22 +64,22 @@ static int mei_txe_probe(struct pci_dev *pdev, > > > const struct pci_device_id *ent)  { > > >         struct mei_device *dev; > > >         struct mei_txe_hw *hw; > > > +       const int mask = BIT(SEC_BAR) | BIT(BRIDGE_BAR); > > > > First line? > > Please be more verbose. Use reversed tree for definition block. The longest lines with the assignment = first; Then lines without assignment; Then return code variable; Flags for spin_lock -- depends. > > > > > +       memcpy(hw->mem_addr, pcim_iomap_table(pdev), > > > + sizeof(hw->mem_addr)); > > > > Why? > > It is kept by PCI core, you don't need a copy. > > There is no simple accessor for that, it's easier to copy the two > dwords then going over the function calls.  I'm not sure you need a copy. That function call just return the pointer to the table. I remember 8250_pci used to have similar approach, now it's using whatever is kept by PCI core. It's less error prone. > > > @@ -256,7 +210,7 @@ static int mei_txe_pci_suspend(struct device > > > *device) > > > -       free_irq(pdev->irq, dev); > > > +       devm_free_irq(&pdev->dev, pdev->irq, dev); > > >         pci_disable_msi(pdev); > > > > All are redundant. Yeah, same clarification as for above case with system sleep. -- Andy Shevchenko Intel Finland Oy