From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga02-in.huawei.com ([119.145.14.65]:52870 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637Ab2GKGoN (ORCPT ); Wed, 11 Jul 2012 02:44:13 -0400 Message-ID: <4FFD1FE7.6010504@huawei.com> Date: Wed, 11 Jul 2012 14:40:39 +0800 From: Jiang Liu MIME-Version: 1.0 To: Bjorn Helgaas CC: Jiang Liu , Don Dutile , Yinghai Lu , Taku Izumi , "Rafael J . Wysocki" , Kenji Kaneshige , Yijing Wang , Keping Chen , , Subject: Re: [RFC PATCH 05/14] PCI: add access functions for PCIe capabilities to hide PCIe spec differences References: <1341935655-5381-1-git-send-email-jiang.liu@huawei.com> <1341935655-5381-6-git-send-email-jiang.liu@huawei.com> <4FFCEDDE.2080907@huawei.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1" Sender: linux-pci-owner@vger.kernel.org List-ID: On 2012-7-11 11:40, Bjorn Helgaas wrote: >> Good point. Return success when reading unimplemented registeres, that >> may simplify code. For we still should return -EINVAL when writing >> unimplemented registers, right? > > Yeah, I guess it's OK to return -EINVAL when *writing* to an > unimplemented register. Hopefully the caller is structured such that > we don't even try to write in that case. It'd be interesting to audit > the callers and explore that, but I haven't done that. Hi Bjorn, Seems it would be better to return error code for unimplemented registers, otherwise following code will becomes more complex. A special error code for unimplemented registers, such as -EIO? static void rtl_disable_clock_request(struct pci_dev *pdev) { u16 ctl; if (!pci_pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &ctl)) { ctl &= ~PCI_EXP_LNKCTL_CLKREQ_EN; pci_pcie_capability_write_word(pdev, PCI_EXP_LNKCTL, ctl); } }