[Intel-gfx] [PATCH 03/29] drm/i915: Replace the aux ddc name switch statement with a table

Chris Wilson chris at chris-wilson.co.uk
Thu Nov 5 06:33:08 PST 2015


On Thu, Nov 05, 2015 at 04:22:09PM +0200, Ville Syrjälä wrote:
> On Thu, Nov 05, 2015 at 02:10:15PM +0000, Chris Wilson wrote:
> > static const char *ddc_name(enum port port) {
> > 	static const char * const names[] = {
> > 		[PORT_A] = "DPDDC-A",
> > 		[PORT_B] = "DPDDC-B",
> > 		[PORT_C] = "DPDDC-C",
> > 		[PORT_D] = "DPDDC-D",
> > 		[PORT_E] = "DPDDC-E",
> > 	};
> > 	if (WARN_ON(port >= ARRAY_SIZE(names))
> > 		return "DPDDC-XXX";
> > 	return names[port];
> > }
> 
> We can do that. Or we could just do
> kasprintf(GFP_KERNEL, "DPDDC-%c", port_name(port));
> 
> + error handling and kfree() along drm_dp_aux_unregister()
> of course.

Aye, that's better.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list