@@ -332,6 +332,19 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
332332 */
333333int __must_check clk_bulk_get_all (struct device * dev ,
334334 struct clk_bulk_data * * clks );
335+
336+ /**
337+ * clk_bulk_get_optional - lookup and obtain a number of references to clock producer
338+ * @dev: device for clock "consumer"
339+ * @num_clks: the number of clk_bulk_data
340+ * @clks: the clk_bulk_data table of consumer
341+ *
342+ * Behaves the same as clk_bulk_get() except where there is no clock producer.
343+ * In this case, instead of returning -ENOENT, the function returns 0 and
344+ * NULL for a clk for which a clock producer could not be determined.
345+ */
346+ int __must_check clk_bulk_get_optional (struct device * dev , int num_clks ,
347+ struct clk_bulk_data * clks );
335348/**
336349 * devm_clk_bulk_get - managed get multiple clk consumers
337350 * @dev: device for clock "consumer"
@@ -346,6 +359,28 @@ int __must_check clk_bulk_get_all(struct device *dev,
346359 */
347360int __must_check devm_clk_bulk_get (struct device * dev , int num_clks ,
348361 struct clk_bulk_data * clks );
362+ /**
363+ * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks
364+ * @dev: device for clock "consumer"
365+ * @clks: pointer to the clk_bulk_data table of consumer
366+ *
367+ * Behaves the same as devm_clk_bulk_get() except where there is no clock
368+ * producer. In this case, instead of returning -ENOENT, the function returns
369+ * NULL for given clk. It is assumed all clocks in clk_bulk_data are optional.
370+ *
371+ * Returns 0 if all clocks specified in clk_bulk_data table are obtained
372+ * successfully or for any clk there was no clk provider available, otherwise
373+ * returns valid IS_ERR() condition containing errno.
374+ * The implementation uses @dev and @clk_bulk_data.id to determine the
375+ * clock consumer, and thereby the clock producer.
376+ * The clock returned is stored in each @clk_bulk_data.clk field.
377+ *
378+ * Drivers must assume that the clock source is not enabled.
379+ *
380+ * clk_bulk_get should not be called from within interrupt context.
381+ */
382+ int __must_check devm_clk_bulk_get_optional (struct device * dev , int num_clks ,
383+ struct clk_bulk_data * clks );
349384/**
350385 * devm_clk_bulk_get_all - managed get multiple clk consumers
351386 * @dev: device for clock "consumer"
@@ -718,6 +753,12 @@ static inline int __must_check clk_bulk_get(struct device *dev, int num_clks,
718753 return 0 ;
719754}
720755
756+ static inline int __must_check clk_bulk_get_optional (struct device * dev ,
757+ int num_clks , struct clk_bulk_data * clks )
758+ {
759+ return 0 ;
760+ }
761+
721762static inline int __must_check clk_bulk_get_all (struct device * dev ,
722763 struct clk_bulk_data * * clks )
723764{
@@ -741,6 +782,12 @@ static inline int __must_check devm_clk_bulk_get(struct device *dev, int num_clk
741782 return 0 ;
742783}
743784
785+ static inline int __must_check devm_clk_bulk_get_optional (struct device * dev ,
786+ int num_clks , struct clk_bulk_data * clks )
787+ {
788+ return 0 ;
789+ }
790+
744791static inline int __must_check devm_clk_bulk_get_all (struct device * dev ,
745792 struct clk_bulk_data * * clks )
746793{
0 commit comments