Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261710AbUKHN4P (ORCPT ); Mon, 8 Nov 2004 08:56:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261839AbUKHN4P (ORCPT ); Mon, 8 Nov 2004 08:56:15 -0500 Received: from parcelfarce.linux.theplanet.co.uk ([195.92.249.252]:46743 "EHLO www.linux.org.uk") by vger.kernel.org with ESMTP id S261710AbUKHN4I (ORCPT ); Mon, 8 Nov 2004 08:56:08 -0500 Date: Mon, 8 Nov 2004 13:56:06 +0000 From: Matthew Wilcox To: Li Shaohua Cc: ACPI-DEV , lkml , Len Brown , Greg , Patrick Mochel Subject: Re: [ACPI] [PATCH/RFC 0/4]Bind physical devices with ACPI devices Message-ID: <20041108135606.GA2685@parcelfarce.linux.theplanet.co.uk> References: <1099887066.1750.241.camel@sli10-desk.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1099887066.1750.241.camel@sli10-desk.sh.intel.com> User-Agent: Mutt/1.4.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3073 Lines: 73 On Mon, Nov 08, 2004 at 12:11:06PM +0800, Li Shaohua wrote: > ACPI provides many functionalities for physical devices. Such as for > suspend/resume, ACPI can tell us correct devices D-state for S3. There > are tons of devices enhancement for both realtime and boot time from > ACPI. To utilize ACPI, physical devices like PCI devices must know its > partner. The patches try to do this. After this is done, we can enhance > many features, such as improve suspend/resume. > These patches are against 2.6.10-rc1, please give your comments. I don't think this is a great way to do it. There's at least two other examples of firmware that interacts with drivers in a similar way that you could look at -- PA-RISC's PDC and Sun/Apple/IBM OpenFirmware. I don't know much about OpenFirmware, and I just redid the way parisc_device works, so I'll discourse about that for a bit. >From a driver's point of view, it's simple. Call a function to get a cookie (an acpi_handle for ACPI, I guess), then pass that cookie to whatever functions necessary. This is the code in the sym2 SCSI driver: #ifdef CONFIG_PARISC /* * Host firmware (PDC) keeps a table for altering SCSI capabilities. * Many newer machines export one channel of 53c896 chip as SE, 50-pin HD. * Also used for Multi-initiator SCSI clusters to set the SCSI Initiator ID. */ static int sym_read_parisc_pdc(struct sym_device *np, struct pdc_initiator *pdc) { struct hardware_path hwpath; get_pci_node_path(np->pdev, &hwpath); if (!pdc_get_initiator(&hwpath, pdc)) return 0; return SYM_PARISC_PDC; } #else static int sym_read_parisc_pdc(struct sym_device *np, struct pdc_initiator *x) { return 0; } #endif Hm.. ACPI doesn't really hanve anything SCSI-related in it. Let's look at IDE's _GTM and _STM for examples. static void ide_acpi_gtm(struct hwif_s *hwif, struct acpi_timing_mode *tm) { acpi_handle handle; acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; acpi_status status; handle = acpi_get_gendev_handle(&hwif->gendev); status = acpi_evaluate_object(handle, "_GTM", NULL, &buffer); ... } All we need is an acpi_get_gendev_handle that takes a struct device and returns the acpi_handle for it. Now, maybe that'd be best done by placing a pointer in the struct device, but I bet it'd be just as good to walk the namespace looking for the corresponding device. -- "Next the statesmen will invent cheap lies, putting the blame upon the nation that is attacked, and every man will be glad of those conscience-soothing falsities, and will diligently study them, and refuse to examine any refutations of them; and thus he will by and by convince himself that the war is just, and will thank God for the better sleep he enjoys after this process of grotesque self-deception." -- Mark Twain - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/